package org.ncibi.cytoscape.metscape.action;

import java.awt.event.ActionEvent;
import java.util.HashMap;
import java.util.Map;

import org.ncibi.cytoscape.metscape.multidisplay.gui.select.AnimationDataSelectionDialog;

import cytoscape.CyNetwork;
import cytoscape.Cytoscape;
import cytoscape.util.CytoscapeAction;

@SuppressWarnings("serial")
public class AnimateAction extends CytoscapeAction {
	
	public static final String NAME = "Animate...";
	private Map<CyNetwork, AnimationDataSelectionDialog> dialogs = new HashMap<CyNetwork, AnimationDataSelectionDialog>();
	
	/**
	 * The constructor sets the text that should appear on the menu item.
	 */
	public AnimateAction() {
		super(NAME);
	}

	/**
	 * This method is called when the user selects the menu item.
	 */
	public void actionPerformed(ActionEvent ae) {
		CyNetwork network = Cytoscape.getCurrentNetwork();
		AnimationDataSelectionDialog dialog = dialogs.get(network);
		if(dialog == null) {
			dialog = new AnimationDataSelectionDialog(Cytoscape.getDesktop());
			dialogs.put(network, dialog);
		}
		dialog.start();
	}
	
}
